import QtQuick 2.0
import SvgImage 1.0

Rectangle {
    id: closeBtn
    color: "transparent"
    property string source_image_normal: "qrc:/image/window_close.svg"
    property string source_image_hovered: "qrc:/image/window_close.svg"

    Rectangle {
        anchors.left: closeBtn.left
        anchors.top: closeBtn.top
        anchors.bottom: closeBtn.bottom
        implicitWidth: closeBtn.radius
        color: closeBtn.color
    }

    Rectangle {
        anchors.right: closeBtn.right
        anchors.bottom: closeBtn.bottom
        implicitWidth: closeBtn.radius
        implicitHeight: closeBtn.radius
        color: closeBtn.color
    }

    SvgImage {
        id: btnImage
        anchors.fill: parent
        source: source_image_normal
    }

    MouseArea {
        anchors.fill: parent
        hoverEnabled: true
        onClicked: { close(); focus = true }
        onPressed: closeBtn.color = "#FF4141"
        onEntered: {
            closeBtn.color = "#FF6C6C"
            btnImage.source = source_image_hovered
        }
        onExited: {
            closeBtn.color = "transparent"
            btnImage.source = source_image_normal
        }
    }
}
